<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>web work</title>
	</head>
	<body>
		<button id="start">start worker</button>
		<button id="stop">stop worker</button>
		<script>
			var start=document.getElementById("start");
			start.addEventListener("click",function(){
				if(typeof(worker)!=undefined){
					//可以调用
					w=new Worker("demo_worker.js");
					
				}else{
					//不支持
				}
			});
			var stop=document.getElementById("stop");
			stop.addEventListener("click",function(){
				if(typeof(worker)!=undefined){
					//可以调用
					w.terminate();
					w=undefined;
				}else{
					//不支持
				}
			})
			
			
		</script>
	</body>
</html>